package com.xm.servlet.background.employee;

import com.google.gson.Gson;
import com.xm.entity.AdministratorInformation;
import com.xm.service.background.AdministratorInformationService;
import lombok.SneakyThrows;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * 员工Servlet
 *
 * @author 陈盼
 * @date 2023-01-11 上午 09:10
 */
@WebServlet("/background/add/employee")

public class AddEmployeeServlet extends HttpServlet {
    private final AdministratorInformationService service=new AdministratorInformationService();

    @SneakyThrows
    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String administratorInformation = req.getParameter("administratorInformation");
        System.out.println(new Gson().fromJson(administratorInformation, AdministratorInformation.class));
        resp.getWriter().print(service.addAdministratorInformation(new Gson().fromJson(administratorInformation, AdministratorInformation.class)));
    }
}
